package com.drug.mingkang.service.impl;

import com.drug.mingkang.model.ImmPurchase;
import com.drug.mingkang.Mapper.ImmPurchaseMapper;
import com.drug.mingkang.service.ImmPurchaseService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * (ImmPurchase)表服务实现类
 *
 * @author wenchangjian
 * @since 2020-08-11 11:28:44
 */
@Service("immPurchaseService")
public class ImmPurchaseServiceImpl implements ImmPurchaseService {
    @Resource
    private ImmPurchaseMapper immPurchaseMapper;

    /**
     * 通过ID查询单条数据
     *
     * @param purchaseId 主键
     * @return 实例对象
     */
    @Override
    public ImmPurchase queryById(String purchaseId) {
        return this.immPurchaseMapper.queryById(purchaseId);
    }

    /**
     * 查询多条数据
     *
     * @param offset 查询起始位置
     * @param limit 查询条数
     * @return 对象列表
     */
    @Override
    public List<ImmPurchase> queryAllByLimit(int offset, int limit) {
        return this.immPurchaseMapper.queryAllByLimit(offset, limit);
    }

    /**
     * 新增数据
     *
     * @param immPurchase 实例对象
     * @return 实例对象
     */
    @Override
    public ImmPurchase insert(ImmPurchase immPurchase) {
        this.immPurchaseMapper.insert(immPurchase);
        return immPurchase;
    }

    /**
     * 修改数据
     *
     * @param immPurchase 实例对象
     * @return 实例对象
     */
    @Override
    public ImmPurchase update(ImmPurchase immPurchase) {
        this.immPurchaseMapper.update(immPurchase);
        return this.queryById(immPurchase.getPurchaseId());
    }

    /**
     * 通过主键删除数据
     *
     * @param purchaseId 主键
     * @return 是否成功
     */
    @Override
    public boolean deleteById(String purchaseId) {
        return this.immPurchaseMapper.deleteById(purchaseId) > 0;
    }
}